<%@ page import="org.xilin.Teacher" %>

<g:setProvider library="jquery"/>

<x:message message="${flash.message}"/>

<div class="bar">
  <span class="left">Teacher&nbsp;&nbsp;</span>
  <span class="left semester">
      Semester <x:semesterSelection semesterId="${session.activeSemester?.id}"/>
  </span>

  <g:if test="${session.roles?.contains('ROLE_ADMIN')}">
    <span class="btn right">
      <a class="create" href="javascript:void(0)" title="Add Teacher" rel="${request.contextPath}/teacher/create">Add Teacher</a>
    </span>
  </g:if>
</div>

<x:pager/>
<table id="teacherTable" class="tablesorter">
    <thead>
        <tr>
            <th/>
            <th>${message(code: 'teacher.firstName.label', default: 'First Name')}</th>
            <th>${message(code: 'teacher.lastName.label', default: 'Last Name')}</th>
            <th>${message(code: 'teacher.user.username.label', default: 'User Name')}</th>
            <th>${message(code: 'teacher.user.email.label', default: 'Email')}</th>
            <th>${message(code: 'teacher.type.label', default: 'Type')}</th>
            <th>${message(code: 'teacher.course.label', default: 'Course')}</th>
            <g:if test="${session.roles?.contains('ROLE_ADMIN')}">
              <th class="delete">Del</th>
              <th class="edit">Edit</th>
            </g:if>
        </tr>
    </thead>
    <tbody>
    <g:each in="${teacherInstanceList}" status="i" var="teacherInstance">
        <tr>
            <td>${i+1}</td>
            <td>${teacherInstance.firstName}</td>
            <td>${teacherInstance.lastName}</td>
            <td>${teacherInstance.user.username}</td>
            <td>${teacherInstance.user.email}</td>
            <td>${teacherInstance.type}</td>
            <td class="show"><a href="#" title="Course Detail" rel="${request.contextPath}/course/show/${teacherInstance.course?.id}">${fieldValue(bean: teacherInstance, field: "course")}</a></td>
            <g:if test="${session.roles?.contains('ROLE_ADMIN')}">
              <td class="delete"><g:remoteLink action="delete" update="content" before="if(!confirm('Are you sure?')) return false;" id="${teacherInstance.id}"><span class="ui-icon ui-icon-trash"/></g:remoteLink></td>
              <td class="edit"><a href="#" title="Edit Teacher Data" rel="${request.contextPath}/teacher/edit/${teacherInstance.id}"><span class="ui-icon ui-icon-pencil"/></a></td>
            </g:if>
        </tr>
    </g:each>
    </tbody>
</table>

<script type="text/javascript">
  $(function(){
      setupAdminList({controller:'teacher', action:'list'});  
  });
</script>
